import  request  from '@/utils/request'
import {pretty} from '@/utils/request'
import qs from 'qs'
import da from 'element-ui/src/locale/lang/da'

const fileName = '/api-archive'
// const fileName = '/api-archivemanage'
const mediaName = '/api-operate'

const pacsApi = {
  getPortalsLog(id) {
    return request({
      url: mediaName + '/portals/logo?tenancy_id=' + id,
      method: 'get',
      responseType: "blob"
    })
  },
  // 客户信息
  getTenantInfo() {
    return request({
      url: fileName + '/tenant/info',
      method: 'get',
    })
  },
  // 客户信息
  getCompleteDetails() {
    return request({
      url: mediaName + '/tenancies/complete-details',
      method: 'get'
    })
  },
  getInstitutionsList() {
    return request({
      url: fileName + '/tenant/institutions',
      method: 'get'
    })
  },
  getLogo() {
    return request({
      url: fileName + '/tenant/logo',
      method: 'get'
    })
  },
  getLogoPic(id) {
    return request({
      url: mediaName + `/medias/${id}`,
      method: 'get',
      // responseType: 'arraybuffer'
      responseType: "blob"
    })
  },
  getTenanciesLogo(id, tid) {
    return request({
      responseType: 'blob',
      url: mediaName + '/tenancies/logo?id=' + id + '&tenancy_id=' + tid,
      method: 'get'
    })
  },
  getPermissions() {
    return request({
      url: fileName + '/tenant/permissions',
      method: 'get',
    })
  },
  // 基本信息
  getBasicParams(data) {
    return request({
      url: fileName + '/param/basic',
      method: 'get',
      data: data
    })
  },
  saveBasicParams(data) {
    return request({
      url: fileName + '/param/basic',
      method: 'post',
      data: data
    })
  },
  // 影像设备配置
  getImgDeviceList(data) {
    return request({
      url: fileName + '/modalities/listpage',
      method: 'get',
      params: data
    })
  },
  addImgDevice(data) {
    return request({
      url: fileName + '/modalities',
      method: 'post',
      data: data
    })
  },
  modifyImgDevice(data) {
    return request({
      url: fileName + `/modalities/${data.id}/update`,
      method: 'post',
      data: data
    })
  },
  getImgDevice(data) {
   
    return request({
      url: fileName + `/modalities/${data}`,
      method: 'get',
      data: data
    })
  },
  deleteImgDevice(data) {
    return request({
      url: fileName + `/modalities/${data}/delete`,
      method: 'post'
    })
  },
  getImgDeviceAndInstitutionNum() {
    return request({
      url: fileName + '/modalities/institution/statistics',
      method: 'get'
    })
  },
  // 存储设备配置
  getSaveDeviceList() {
    return request({
      url: fileName + '/dicom/devices',
      method: 'get'
    })
  },
  addSaveDevice(data) {
    return request({
      url: fileName + '/dicom/devices',
      method: 'post',
      data: data
    })
  },
  updateSaveDevice(data, id) {
    return request({
      url: fileName + `/dicom/devices/${id}/update`,
      method: 'post',
      data: data
    })
  },
  deleteSaveDevice(data) {
    return request({
      url: fileName + `/dicom/devices/${data}/delete`,
      method: 'post'
    })
  },
  switchSaveDeviceState(data, id) {
    return request({
      url: fileName + `/dicom/devices/${id}/state`,
      method: 'post',
      data: data
    })
  },
  getSaveDevice(data) {
    return request({
      url: fileName + `/dicom/devices/${data}`,
      method: 'get'
    })
  },
  // 测试
  getStrategyVerify(data) {
    return request({
      url: fileName + '/strategy/verify',
      method: 'post',
      data,
      // paramsSerializer: params => {
      //   return qs.stringify(params, { indices: false })
      // }
    })
  },
  getSaveStrategy() {
    return request({
      url: fileName + '/strategy',
      method: 'get'
    })
  },
  updateSaveStrategy(data) {
    return request({
      url: fileName + `/strategy/${data.id}`,
      method: 'post',
      data: data
    })
  },
  getStrategyInfo() {
    return request({
      url: fileName + '/strategy/info',
      method: 'get'
    })
  },
  // 路由策略
  getRouteStrategyList(data) {
    return request({
      url: fileName + '/routingnodes/listpage',
      method: 'get',
      params: data
    })
  },
  getRoutingNodes() {
    return request({
      url: fileName + '/routingnodes',
      method: 'get'
    })
  },
  addRouteDevice(data) {
    return request({
      url: fileName + '/routingnodes',
      method: 'post',
      data: data
    })
  },
  deleteRouteStrategy(data) {
    return request({
      url: fileName + `/routingnodes/${data}/delete`,
      method: 'post'
    })
  },
  updateRouteStrategy(data, id) {
    return request({
      url: fileName + `/routingnodes/${id}/update`,
      method: 'post',
      data: data
    })
  },
  getRouteStrategy(data) {
    return request({
      url: fileName + `/routingnodes/${data}`,
      method: 'get'
    })
  },
  // 影像相关
  getIMGList(data) {
    return request({
      url: fileName + '/studys/listpage',
      method: 'get',
      params: data,
      paramsSerializer: params => {
        let params_new = qs.stringify(params, { indices: false })
        // console.log('参数转换问题',params,params_new);
        return params_new
      }
    })
  },
   // 影像相关--回收站
   getRecycledIMGList(data) {
    return request({
      url: fileName + '/recycled/listpage',
      method: 'get',
      params: data,
      paramsSerializer: params => {
        let params_new = qs.stringify(params, { indices: false })
        // console.log('参数转换问题',params,params_new);
        return params_new
      }
    })
  },
  //回收站---批量删除 recycled/batch/delete
  deleteRecycledImg(data){
    return pretty(request({
      url: fileName + `/recycled/batch/delete`,
      method: 'post',
      data: data,
      paramsSerializer: params => {
        let params_new = qs.stringify(params, { indices: false })
        // console.log('参数转换问题',params,params_new);
        return params_new
      }
    }))
  },

  // 获取检查信息(用于拆分)
  getSplitInfo(accessionNumber) {
    return request({
      url: `${fileName}/studys/accessionnumber/${accessionNumber}`,
      method: 'get'
    })
  },
  getCheckInfo(data) {
    return request({
      url: fileName + `/studys/${data}`,
      method: 'get'
    })
  },
  updateImgModify(data, id) {
    return request({
      url: fileName + `/studys/${id}/update`,
      method: 'post',
      data: data
    })
  },
  deleteImg(data) {

    return pretty(request({
      url: fileName + `/studys/${data}/delete`,
      method: 'post'
    }))
    // return request({
    //   url: fileName + `/studys/${data}/delete`,
    //   method: 'post'
    // })
  },
  deleteSeries(data) {
    return pretty(request({
      url: fileName + `/studys/delete`,
      method: 'post',
      data: data
    }))
  },
  exportImg(data) {
    return request({
      url: fileName + '/studys/export',
      method: 'post',
      data: data
    })
  },
  getSeriesInfo(data) {
    return request({
      url: fileName + `/studys/${data}/series`,
      method: 'get'
    })
  },
  getSeriesImg(data) {
    return request({
      url: fileName + `/series/${data}/image`,
      method: 'get',
      responseType: "blob"
    })
  },
  getSeriesImgList(params){
    return request({
      url: fileName + `/Instance`,
      method: 'get',
      params,
    })
  },
  getInstanceImg(data) {
    return request({
      url: fileName + `/Instance/${data}/image`,
      method: 'get',
      responseType: "blob"
    })
  },
  // transpondImg(data, id) {
  //   return pretty(request({
  //     url: fileName + `/Studys/sending/${id}`,
  //     method: 'post',
  //     data: data
  //   }))
  // },
  sendImg(data, id) {
    return pretty(request({
      url: fileName + `/studys/sending/${id}`,
      method: 'post',
      data: data
    }))
  },
  sendImgListInfo(data) {
    return request({
      url: fileName + '/studys/sending',
      method: 'get',
      params: data
    })
  },
  imgMatchListInfo(data) {
    return request({
      url: fileName + '/studys/match/ris',
      method: 'get',
      params: data
    })
  },
  imgMatch(data, id) {
    return request({
      url: fileName + `/studys/${id}/match`,
      method: 'post',
      data: data
    })
  },
  getSplittingInfo(data) {
    return request({
      url: fileName + '/studys/split/ris',
      method: 'get',
      params: data
    })
  },
  imgSplit(data, id) {
    return request({
      url: fileName + `/studys/${id}/split`,
      method: 'post',
      data: data
    })
  },
  imgStatistics() {
    return request({
      url: fileName + '/studys/statistics/today',
      method: 'get'
    })
  },
  getViewerKey(data) {
    return request({
      url: fileName + `/studys/${data}/viewer`,
      method: 'get'
    })
  },
  getViewUrl(data) {
    return request({
      url: fileName + `/studys/viewer`,
      method: 'get',
      params: data,
      paramsSerializer: params => {
        return qs.stringify(params, { indices: false })
      }
    })
  },
  // 影像浏览
  ViewUrl(data) {
    return request({
      url: '/api-cloudpacs' + '/Composite/Image/ViewUrl',
      method: 'get',
      params: data,
      paramsSerializer: params => {
        return qs.stringify(params, { indices: false })
      }
    })
  },
  // 消息相关
  getSendProgressRate(data) {
    
    return pretty(request({
      url: fileName + `/messages/sending/${data}`,
      method: 'get'
    }))
  },
  // 前置机
  getFrontnodesList(data) {
    return request({
      url: fileName + '/frontnodes/listpage',
      method: 'get',
      params: data
    })
  },
  getFrontnodesInfo() {
    return request({
      url: fileName + '/frontnodes',
      method: 'get'
    })
  },
  getFrontnodes(data) {
    return request({
      url: fileName + `/frontnodes/${data}`,
      method: 'get'
    })
  },
  addFrontnodes(data) {
    return request({
      url: fileName + '/frontnodes',
      method: 'post',
      data: data
    })
  },
  updateFrontnodes(data, id) {
    return request({
      url: fileName + `/frontnodes/${id}/update`,
      method: 'post',
      data: data
    })
  },
  deleteFrontnodes(data) {
    return request({
      url: fileName + `/frontnodes/${data}/delete`,
      method: 'post'
    })
  },
  // 列名列宽 获取 保存
  getColumnCustom(data) {
    return request({
      url: '/api-cloudpacs' + '/Config/ColumnCustom',
      method: 'get',
      params: data
    })
  },
  // 恢复自定义列
  RecoverColumn(data) {
    return request({
      url: '/api-cloudpacs' + '/Composite/Config/ViewColumnCustom/Recover',
      // url: '/api-cloudpacs' + '/Config/ColumnCustom/Recover',
      method: 'get',
      params: data
    })
  },
  // 保存自定义列
  SaveColumnCustom(data) {
    return request({
      url: '/api-cloudpacs' + '/Composite/Config/ViewColumnCustom/Save',
      // url: '/api-cloudpacs' + '/Config/ColumnCustom',
      method: 'post',
      data: data
    })
  },
  // 获取系统列表 - 系统类型 传 2
  getSystemsLiteList(data) {
    return request({
      url: mediaName + '/systems/lite',
      method: 'get',
      params: data
    })
  },
  // 获取机构精简信息列表 - 根据系统ID获取
  getInstitutionsLiteList(data) {
    return request({
      url: mediaName + '/institutions/lite',
      method: 'get',
      params: data
    })
  },
  // 获取检查机房列表 - 根据机构ID获取
  getObseRoom(data) {
    return request({
      url: '/api-cloudpacs' + '/Composite/Config/ObservationRoom',
      // url: '/api-cloudpacs' + '/Config/ObseRoom',
      method: 'get',
      params: data
    })
  },
  // 首页-今日放射检查数
  getRISCount(data) {
    return request({
      url: '/api-cloudpacs' + '/Apply/Statistics/RISRegisteredCount',
      method: 'get',
      params: data
    })
  },
  // 获取系统详情
  getSystemDetail(data) {
    return request({
      url: '/api-operate' + '/systems/detail',
      method: 'get',
      params: data
    })
  },
  // 获取设备类型
  getDicDefine(data) {
    return request({
      url: '/api-cloudpacs' + '/Composite/Config/DataDicDefine',
      // url: '/api-cloudpacs' + '/Config/DicDefine',
      method: 'get',
      params: data
    })
  },
  // 获取日志
  getLog(data) {
    return request({
      url: fileName + '/dicom/log',
      method: 'get',
      params: data
    })
  },
  // 下载日志
  downloadLog(data) {
    return request({
      url: fileName + `/dicom/log/${data.service}/${data.date}/${data.service_type}`,
      method: 'get',
      responseType: 'blob'
    })
  },
  // 影像交换
  imgExchange(id, otherId) {
    return request({
      url: fileName + `/studys/${id}/switch/${otherId}`,
      method: 'post'
    })
  },
  // 影像交换进度
  getExchangeProgressRate() {
    return request({
      url: fileName + '/messages/switch',
      method: 'get'
    })
  },
  // 影像校对列表
  proofreadList(data) {
    return request({
      url: fileName + '/proofread/listpage',
      method: 'get',
      params: data
    })
  },
  // 新增影像校对任务
  addProofread(data) {
    return request({
      url: fileName + '/proofread',
      method: 'post',
      data: data
    })
  },
  // 获取校对进度
  getMessageProofread() {
    return request({
      url: fileName + '/messages/proofread',
      method: 'get'
    })
  },
  // 导出校对结果
  proofreadExport() {
    return request({
      url: fileName + '/proofread/export',
      method: 'get',
      responseType: 'blob',
      paramsSerializer: params => {
        return qs.stringify(params, { indices: false })
      }
    })
  },
  // 停止校对
  stopProofread() {
    return request({
      url: fileName + '/proofread/stop',
      method: 'post',
    })
  },
  // 删除校对结果
  deleteProofread(data) {
    return request({
      url: fileName + '/proofread/delete',
      method: 'post',
      data: data
    })
  },
  // 校验密码
  checkPassword(params) {
    return request({
      url: '/api-cloudpacs/Common/CheckPassword',
      method: 'post',
      data: params
    })
  },
  //路由列表
  getRouteList(params){
    return pretty(request({
      url: fileName + '/RoutingTask/listpage',
      method: 'get',
      params,
    }))
  },
  //删除路由
  deleteRoute(data){
    return pretty(request({
      url: fileName + `/RoutingTask/delete`,
      method: 'post',
      data:data,
    }))
  },
  //重新路由
  reRoute(data){
    return pretty(request({
      url: fileName + `/RoutingTask/reroute`,
      method: 'post',
      data:data,
    }))
  },
  getUploadImageDetail(params){
    return pretty(request({
      url: fileName + `/Instance/upload`,
      method: 'get',
      params,
    }))
  }

  
 
}

 
export default {
  pacsApi
}
